﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DAL.Abstract;
using System.Data.SqlClient;

namespace DAL.Classes
{
    public class PropagandaDAL: abstractDAL
    {
        public Propaganda getPropagandaByID(int id)
        {
            try
            {
                return (from p in Wiki.Propagandas where p.idPropaganda == id select p).SingleOrDefault();
            }
            catch (SqlException)
            {
                throw;
            }
        }


        public List<Propaganda> getAllPropaganda()
        {
            try
            {
                return (from p in Wiki.Propagandas select p).ToList();
            }
            catch (Exception)
            {
                
                throw;
            }
        }
        public void deletePropaganda(Propaganda propaganda)
        {
            try
            {
                Wiki.Propagandas.DeleteOnSubmit(propaganda);
                Wiki.SubmitChanges();

            }
            catch (SqlException)
            {
                throw;
            }
        }
        public void InsertPropaganda(Propaganda propaganda)
        {
            try
            {
                Wiki.Propagandas.InsertOnSubmit(propaganda);
                Wiki.SubmitChanges();
            }
            catch (SqlException)
            {
                throw;
            }
        }
    }
}
